Load necessary packages and set the working directory:

1. Loading raw pileup data and generate seperate dataframes for CL 7 NG samples:

Through this step by dropping “LBP” column, we prepare the dataframe for normalisation!

df  <- read.table("ReadDepth.txt")
dplyr::select(df, contains("CL")) -> cl
dplyr::select(df, contains("NG")) -> ng
RD  <- dplyr::bind_cols(cl,ng)
pos  <- dplyr::select(df, LBP)

2. Normalizing the data using ‘n4: (x-min)/range)’ option:

data.Normalization(cl, type = "n4", normalization = "column")  ->  clNorm
data.Normalization(ng, type = "n4", normalization = "column")  ->  ngNorm

3. Putting back normalised dataframs together along with base-pair positions in order to prepare the final single dataframe:

dplyr::bind_cols(pos,clNorm,ngNorm) -> RDnorM
dplyr::mutate(RDnorM, pos = seq(from = 1, to=3263)) -> normDF

4. Generating plots and convert them to ggplotly format:

cl21  <- geom_line(aes(y=CL021, col="CL021"))
cl22  <- geom_line(aes(y=CL022, col="CL022"))
cl24  <- geom_line(aes(y=CL024, col="CL024"))
cl25  <- geom_line(aes(y=CL025, col="C025L"))
cl27  <- geom_line(aes(y=CL027, col="CL027"))
cl28  <- geom_line(aes(y=CL028, col="CL028"))
cl30  <- geom_line(aes(y=CL030, col="CL030"))
cl33  <- geom_line(aes(y=CL033, col="CL033"))
cl35  <- geom_line(aes(y=CL035, col="CL035"))
cl36  <- geom_line(aes(y=CL036, col="CL036"))
cl37  <- geom_line(aes(y=CL037, col="CL037"))
cl38  <- geom_line(aes(y=CL038, col="CL038"))
cl39  <- geom_line(aes(y=CL039, col="CL039"))
cl40  <- geom_line(aes(y=CL040, col="CL040"))
ng172  <- geom_line(aes(y=NG172, col="NG"))
ng176  <- geom_line(aes(y=NG176, col="NG"))
ng178  <- geom_line(aes(y=NG178, col="NG"))
ng190  <- geom_line(aes(y=NG190, col="NG"))
ng191  <- geom_line(aes(y=NG191, col="NG"))
ng195  <- geom_line(aes(y=NG195, col="NG"))
ng218  <- geom_line(aes(y=NG218, col="NG"))
ng232  <- geom_line(aes(y=NG232, col="NG"))
ng244  <- geom_line(aes(y=NG244, col="NG"))
ng264  <- geom_line(aes(y=NG264, col="NG"))
ng285  <- geom_line(aes(y=NG285, col="NG"))
ng289  <- geom_line(aes(y=NG289, col="NG"))
ng299  <- geom_line(aes(y=NG299, col="NG"))
ng302  <- geom_line(aes(y=NG302, col="NG"))
ng306  <- geom_line(aes(y=NG306, col="NG"))
ng318  <- geom_line(aes(y=NG318, col="NG"))
ng320  <- geom_line(aes(y=NG320, col="NG"))
ng335  <- geom_line(aes(y=NG335, col="NG"))
ng338  <- geom_line(aes(y=NG338, col="NG"))
ng367  <- geom_line(aes(y=NG367, col="NG"))
ggplot(normDF, aes(x=pos, y= value))+ cl21 +cl22  +cl24 +cl25 +cl27 +cl28 +cl30 +cl33 +cl35 +cl36 +cl37 +cl38 +cl39 +cl40 + ng172+ ng176+ ng178+ ng190+ ng191+ ng195+ ng218+ ng232+ ng244+ ng264+ ng285+ ng289+ ng299+ ng302+ ng306+ ng318+ ng320+ ng335+ ng338+ ng367  -> p
p

ggplotly(p)